#include "teacher.h"
#include "ui_teacher.h"
#include<QMessageBox>
#include <QSqlQuery>
#include <QSqlQueryModel>
#include"formt.h"
#include<QDebug>
#include"formtkaoqin.h"
//#include"formtclass.h"
#include"formmode.h"
#include"changeinfo.h"
#include"login.h"
#include"teacherinfo.h"

#include <QStackedLayout>
#include <QPushButton>
#include <QVBoxLayout>


Teacher::Teacher(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Teacher)
{
    ui->setupUi(this);

}
Teacher::~Teacher()
{
    delete ui;
}

void Teacher::selectBoxSlot(QString T)//查询箱子状态
{

    bool ok = connectsqliteT.ok;
    if(ok)
    {
        QSqlQueryModel *model = new QSqlQueryModel(ui->tableView_T);

        model->setQuery(QString("select * from TeacherInfoTable where ID = '%1';").arg(T));
        //列名
        model->setHeaderData(0, Qt::Horizontal, tr("ID"));
        model->setHeaderData(2, Qt::Horizontal, tr("XID"));
        model->setHeaderData(1, Qt::Horizontal, tr("TeacherId"));
        model->setHeaderData(3, Qt::Horizontal, tr("Name"));
        model->setHeaderData(4, Qt::Horizontal, tr("Sex"));
        model->setHeaderData(5, Qt::Horizontal, tr("Birth"));
        model->setHeaderData(6, Qt::Horizontal, tr("loginpw"));
        model->setHeaderData(7, Qt::Horizontal, tr("face"));

        ui->tableView_T->setModel(model);//数据放置进去
        ui->tableView_T->verticalHeader()->hide();//不显示序号
    }
    else
    {
        QMessageBox::warning(this,"错误","未连接，请检查.");
    }
    T1 = T;
}

void Teacher::slotformt()
{
    formTW->show();
    formTW->str = T1;
}

void Teacher::slotformmode()
{
    formmodeTW->show();
    formmodeTW->str = T1;
}

void Teacher::slotformtkaoqin()
{
    formtkaoqinW->show();
    formtkaoqinW->str = T1;
}

void Teacher::slotchangeinfo()
{
    changeinfoW->show();
    changeinfoW->str = T1;
}

void Teacher::on_pb_forgetpswd_clicked()
{
    formTW = new FormT;
    connect(formTW,&FormT::signalformt,this,&Teacher::slotformt);
    this->hide();
    formTW->showformt();
}

void Teacher::on_pb_modify_clicked()
{
    changeinfoW = new changeinfo;
    connect(changeinfoW,&changeinfo::signalchangeinfo,this,&Teacher::slotchangeinfo);
    this->hide();
    changeinfoW->showchangeinfo();
}

void Teacher::on_pb_class_clicked()
{
    formmodeTW = new FormMode;
    connect(formmodeTW,&FormMode::signalformmode,this,&Teacher::slotformmode);
    this->hide();
    formmodeTW->showformmode();
}

void Teacher::on_pb_kaoqin_clicked()
{
    formtkaoqinW = new FormTkaoqin;
    connect(formtkaoqinW,&FormTkaoqin::signalformtkaoqin,this,
        &Teacher::slotformtkaoqin);
    this->hide();
      formtkaoqinW->showFormTkaoqin();
}

void Teacher::on_pb_holiday_clicked()
{
    pronew.startDetached("D:\\openmv\\bin\\openmvide.exe",QStringList());
        if(pronew.isOpen() == false)
        {
            pronew.close();
        }
}
